﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EnvDTE;
using SPVisualDev.VSAddin.Dialogs.PropertySheets;

namespace SPVisualDev.VSAddin.Dialogs
{
    public partial class DialogWebApplicationSelector : Form
    {
        private SpecialProject m_project;
        private List<string[]> m_web_app_list_init;

        public DialogWebApplicationSelector(SpecialProject project)
        {
            InitializeComponent();

            m_project = project;
        }

        public ListView WebApplicationsListView
        {
            get { return this.lstWebApplications; }
        }

        public string InfoMessage
        {
            get { return this.lblInfo.Text; }
            set { this.lblInfo.Text = value; }
        }

        public List<string[]> WebApplicationsList
        {
            get
            {
                m_web_app_list_init.Clear();

                foreach (ListViewItem item in this.lstWebApplications.Items)
                {
                    m_web_app_list_init.Add(new string[] { item.Text, item.SubItems[1].Text, item.Checked.ToString() });
                }

                return m_web_app_list_init;
            }
            set
            {
                m_web_app_list_init = value;

                this.lstWebApplications.Items.Clear();

                foreach (string[] webapp in m_web_app_list_init)
                {
                    ListViewItem item = new ListViewItem(webapp);

                    if (webapp.Length > 2 && webapp[2] == "True")
                        item.Checked = true;

                    if (webapp.Length > 3 && webapp[3] == "True")
                        item.Selected = true;

                    this.lstWebApplications.Items.Add(item);
                }
            }
        }
    }
}
